module JdnbbHelper
  def link_to_module(name, image)
    return  %@
      <table id=\"#{name}Icon\"  border=\"0\" class=\"icon\">
        <tr>
          <td align=\"center\">
            #{  link_to_remote( image_tag("pics/#{image}",  :class => "imagen"),    :url => { :controller => name, :action => 'list'},  :update => "main")}
          </td>
        </tr>
        <tr>
          <td align=\"center\"> 
            #{link_to_remote( name.capitalize, :url => { :controller => name, :action => 'list'},  :update => "main")}
          </td>
        </tr>
    </table>
    @
  end
  
  def add_section(title, body, actionMore = nil )
    linkToMore = ""
    linkToMore =  link_to_remote 'ver m&#225;s', :url => { :controller => 'jdnbb', :action => actionMore}, :update => 'main'  if not actionMore.nil?
    
    result =  %@
        <table class="" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td class="mac_os_x_nw"></td>
						<td class="mac_os_x_n" valign="bottom" ><font style="font-weight: bold; font-family: Trebuchet MS;">#{title}</font></td>
						<td class="mac_os_x_ne"></td>
					</tr>
					<tr>
						<td class="mac_os_x_w"></td>
						<td class="mac_os_x_content">
							#{body}
              #{linkToMore}
						</td>
						<td class="mac_os_x_e"></td>
					</tr>
					<tr>
						<td class="mac_os_x_sw"></td>
						<td class="mac_os_x_s"></td>
						<td class="mac_os_x_se"></td>
					</tr>
				</table>
    @
    return result;
  end
  
  def show_notice( title, body, author, date )
    result =  %@
        <table class="m_widget" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td class="mac_os_x_nw"></td>
						<td class="mac_os_x_n" valign="bottom" ><font style="font-weight: bold; font-family: Trebuchet MS">#{title}</font></td>
						<td class="mac_os_x_ne"></td>
					</tr>
					<tr>
						<td class="mac_os_x_w"></td>
						<td class="mac_os_x_content" margin="10">
    #{body}
						</td>
						<td class="mac_os_x_e"></td>
					</tr>
          <tr>
            <td class="mac_os_x_w"></td>
            <td class="mac_os_x_content">
            <small>Escrito por #{ author } el #{date.to_s} </small>
            </td>
            <td class="mac_os_x_e"></td>
          </tr>
					<tr>
						<td class="mac_os_x_sw"></td>

						<td class="mac_os_x_s"></td>
						<td class="mac_os_x_se"></td>
					</tr>
				</table>
    @
  end
  
  def row_tag num
    style = "fila_clara"
    style = "fila_oscura" if num.odd?
    return %@ <tr class='#{style}'> @
  end
  
  def logout_link
  	link_to ( "Salir",  { :controller => "account", :action => 'logout'}, {:class => "link_lo"} ,:confirm => "Gracias por su preferencia")
  end
  
	  
	def current_user_loged (user_id)
		user = User.find(:first,:conditions => "id='#{user_id.to_i}'")
		result = %@
			<font style="font-weight: bold; font-family: Trebuchet MS">Usuario: &nbsp; #{user.login}</font>
		@
	end
end
